/*
 * @Description: 用户登录状态模块
 * @Author: pdx
 * @Date: 2020-10-8 13:40:18
 * @LastEditors: pdx
 * @LastEditTime: 2020-10-8 13:40:18
 */
export default {
  state: {
    user: {
      memberWishIds: []  //心愿单
    }, // 登录的用户
  },
  getters: {
    getUser (state) {
      return state.user
    },
  },

  mutations: {
    setUser (state, data) {
      state.user = data;
    },

    setWishGameIds(state, data) {
      state.user.memberWishIds = data
    },

    //添加心愿单游戏id
    addWishGameIds(state, data) {
      state.user.memberWishIds.push(data)
    },

    //删除心愿单游戏id
    removeWishGameId(state, data) {
      let index = state.user.memberWishIds.indexOf(data)
      state.user.memberWishIds.splice(index, 1)
    }
  },

  actions: {
    setUser ({ commit }, data) {
      commit('setUser', data);
    },

    setWishGameIds({commit}, data) {
      commit('setWishGameIds', data)
    },

    addWishGameIds({commit}, data) {
      commit('addWishGameIds', data)
    },

    removeWishGameId({commit}, data) {
      commit('removeWishGameId', data)
    },
  },

}